package com.edu.mapper;

import com.edu.bean.Book;
import jdk.nashorn.internal.objects.annotations.Setter;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @Author:max
 * @Date: 2024/9/21 17:45
 * @Description:
 */

public interface BookMapper {
    @Select("select* from book where bookId = #{id}")
    Book selectById(int id);

    @Select("select * from book")
    List<Book> selectAll();

    @Insert("insert into book (bookName,bookWriter,bookType) values(#{bookName},#{bookWriter},#{bookType})")
    void addBook(@Param("bookName") String bookName,@Param("bookWriter") String bookWriter,@Param("bookType") String bookType);

    @Delete("delete from book where bookId=#{id}")
    void deleteBook(int id);

    @Update(" UPDATE book SET  bookName=#{bookName},bookWriter=#{bookWriter},bookType=#{bookType} WHERE bookId = #{bookId}")
    void updateBook(@Param("bookName") String bookName,@Param("bookWriter") String bookWriter,@Param("bookType") String bookType,@Param("bookId") int bookId);
}
